uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:
Class:
Gets or sets whether the current uCalc instance is the active default for the current thread.
The IsDefault property gets or sets whether the current uCalc instance is the active default instance for the current thread. This default instance serves two main purposes:
uCalc instance, automatically use the default one for their context.uCalc instance via its constructor, it is initialized as a clone of the current default instance, inheriting all its functions, variables, and settings.Instead of a single, rigid global object, uCalc manages a stack of default instances using a LIFO (Last-In, First-Out) model. This provides a flexible, layered context system.
The instance at the top of the stack is the active default, which is returned by DefaultInstance.
Getter: var isDefault = myInstance.IsDefaultReturns true if myInstance is currently at the top of the default stack; otherwise, false.
Setter: myInstance.IsDefault = truePromotes myInstance to the top of the stack, making it the new active default.
Setter: myInstance.IsDefault = falseRemoves myInstance from the stack, wherever it may be. If it was the active default, the previously active instance is automatically restored.
The recommended way to manage temporary contexts is to combine @IsDefault with a using (var uc = new uCalc()) { block. When the scope is exited, the uCalc instance is automatically released and popped from the stack, cleanly restoring the previous default.
csharp
// Main context is active here
using (var tempContext = new uCalc()) {
tempContext.IsDefault = true;
// tempContext is now the active default within this block
}
// The original default context is automatically restored here
uCalc instance and set that as your application's primary default.using blocks or call @IsDefault(false) to clean up temporary defaults and prevent unexpected behavior.In standard C# or C++, managing a "global" context requires careful design patterns.
uCalc's default instance model offers a pragmatic middle ground, providing the convenience of a static/singleton approach while retaining the flexibility of having multiple, swappable configurations.
ID: 366
using uCalcSoftware;
var uc = new uCalc();
// The implicit 'uc' object is not the default upon creation.
Console.WriteLine($"Is 'uc' the default instance? {uc.IsDefault}");
// Create a new uCalc instance. It also won't be the default.
var myCalc = new uCalc();
Console.WriteLine($"Is 'myCalc' the default instance? {myCalc.IsDefault}");
// Let's get the actual default instance and check it.
uCalc defaultInstance = uCalc.DefaultInstance;
Console.WriteLine($"Is the instance from uCalc.DefaultInstance the default? {defaultInstance.IsDefault}");
Is 'uc' the default instance? False
Is 'myCalc' the default instance? False
Is the instance from uCalc.DefaultInstance the default? True using uCalcSoftware; var uc = new uCalc(); // The implicit 'uc' object is not the default upon creation. Console.WriteLine($"Is 'uc' the default instance? {uc.IsDefault}"); // Create a new uCalc instance. It also won't be the default. var myCalc = new uCalc(); Console.WriteLine($"Is 'myCalc' the default instance? {myCalc.IsDefault}"); // Let's get the actual default instance and check it. uCalc defaultInstance = uCalc.DefaultInstance; Console.WriteLine($"Is the instance from uCalc.DefaultInstance the default? {defaultInstance.IsDefault}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
// The implicit 'uc' object is not the default upon creation.
cout << "Is 'uc' the default instance? " << tf(uc.IsDefault()) << endl;
// Create a new uCalc instance. It also won't be the default.
uCalc myCalc;
cout << "Is 'myCalc' the default instance? " << tf(myCalc.IsDefault()) << endl;
// Let's get the actual default instance and check it.
uCalc defaultInstance = uCalc::DefaultInstance();
cout << "Is the instance from uCalc.DefaultInstance the default? " << tf(defaultInstance.IsDefault()) << endl;
}
Is 'uc' the default instance? False
Is 'myCalc' the default instance? False
Is the instance from uCalc.DefaultInstance the default? True #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; // The implicit 'uc' object is not the default upon creation. cout << "Is 'uc' the default instance? " << tf(uc.IsDefault()) << endl; // Create a new uCalc instance. It also won't be the default. uCalc myCalc; cout << "Is 'myCalc' the default instance? " << tf(myCalc.IsDefault()) << endl; // Let's get the actual default instance and check it. uCalc defaultInstance = uCalc::DefaultInstance(); cout << "Is the instance from uCalc.DefaultInstance the default? " << tf(defaultInstance.IsDefault()) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// The implicit 'uc' object is not the default upon creation.
Console.WriteLine($"Is 'uc' the default instance? {uc.IsDefault}")
'// Create a new uCalc instance. It also won't be the default.
Dim myCalc As New uCalc()
Console.WriteLine($"Is 'myCalc' the default instance? {myCalc.IsDefault}")
'// Let's get the actual default instance and check it.
Dim defaultInstance As uCalc = uCalc.DefaultInstance
Console.WriteLine($"Is the instance from uCalc.DefaultInstance the default? {defaultInstance.IsDefault}")
End Sub
End Module
Is 'uc' the default instance? False
Is 'myCalc' the default instance? False
Is the instance from uCalc.DefaultInstance the default? True Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// The implicit 'uc' object is not the default upon creation. Console.WriteLine($"Is 'uc' the default instance? {uc.IsDefault}") '// Create a new uCalc instance. It also won't be the default. Dim myCalc As New uCalc() Console.WriteLine($"Is 'myCalc' the default instance? {myCalc.IsDefault}") '// Let's get the actual default instance and check it. Dim defaultInstance As uCalc = uCalc.DefaultInstance Console.WriteLine($"Is the instance from uCalc.DefaultInstance the default? {defaultInstance.IsDefault}") End Sub End Module
ID: 367
using uCalcSoftware;
var uc = new uCalc();
// Setup a "Scientific" configuration
var scientificCalc = new uCalc();
scientificCalc.DefineFunction("sqrt(x) = x^0.5");
scientificCalc.DefineVariable("pi = 3.14159");
// Setup a "Financial" configuration
var financialCalc = new uCalc();
financialCalc.DefineFunction("tax(amount, rate) = amount * (rate/100)");
// Set the scientific calculator as the default
scientificCalc.IsDefault = true;
Console.WriteLine($"Current default is scientific? {scientificCalc.IsDefault}");
// Components that rely on the default instance now use the scientific setup.
uCalc.Expression expr1 = "2 * pi";
Console.WriteLine($"2 * pi = {expr1.Evaluate()}");
// Now, switch the default to the financial calculator
financialCalc.IsDefault = true;
Console.WriteLine($"Current default is scientific? {scientificCalc.IsDefault}"); // Should be false now
Console.WriteLine($"Current default is financial? {financialCalc.IsDefault}");
// New components will use the financial setup.
uCalc.Expression expr2 = "tax(50000, 20)";
Console.WriteLine($"Tax on 50000 at 20% = {expr2.Evaluate()}");
Current default is scientific? True
2 * pi = 6.28318
Current default is scientific? False
Current default is financial? True
Tax on 50000 at 20% = 10000 using uCalcSoftware; var uc = new uCalc(); // Setup a "Scientific" configuration var scientificCalc = new uCalc(); scientificCalc.DefineFunction("sqrt(x) = x^0.5"); scientificCalc.DefineVariable("pi = 3.14159"); // Setup a "Financial" configuration var financialCalc = new uCalc(); financialCalc.DefineFunction("tax(amount, rate) = amount * (rate/100)"); // Set the scientific calculator as the default scientificCalc.IsDefault = true; Console.WriteLine($"Current default is scientific? {scientificCalc.IsDefault}"); // Components that rely on the default instance now use the scientific setup. uCalc.Expression expr1 = "2 * pi"; Console.WriteLine($"2 * pi = {expr1.Evaluate()}"); // Now, switch the default to the financial calculator financialCalc.IsDefault = true; Console.WriteLine($"Current default is scientific? {scientificCalc.IsDefault}"); // Should be false now Console.WriteLine($"Current default is financial? {financialCalc.IsDefault}"); // New components will use the financial setup. uCalc.Expression expr2 = "tax(50000, 20)"; Console.WriteLine($"Tax on 50000 at 20% = {expr2.Evaluate()}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
// Setup a "Scientific" configuration
uCalc scientificCalc;
scientificCalc.DefineFunction("sqrt(x) = x^0.5");
scientificCalc.DefineVariable("pi = 3.14159");
// Setup a "Financial" configuration
uCalc financialCalc;
financialCalc.DefineFunction("tax(amount, rate) = amount * (rate/100)");
// Set the scientific calculator as the default
scientificCalc.IsDefault(true);
cout << "Current default is scientific? " << tf(scientificCalc.IsDefault()) << endl;
// Components that rely on the default instance now use the scientific setup.
uCalc::Expression expr1 = "2 * pi";
cout << "2 * pi = " << expr1.Evaluate() << endl;
// Now, switch the default to the financial calculator
financialCalc.IsDefault(true);
cout << "Current default is scientific? " << tf(scientificCalc.IsDefault()) << endl; // Should be false now
cout << "Current default is financial? " << tf(financialCalc.IsDefault()) << endl;
// New components will use the financial setup.
uCalc::Expression expr2 = "tax(50000, 20)";
cout << "Tax on 50000 at 20% = " << expr2.Evaluate() << endl;
}
Current default is scientific? True
2 * pi = 6.28318
Current default is scientific? False
Current default is financial? True
Tax on 50000 at 20% = 10000 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; // Setup a "Scientific" configuration uCalc scientificCalc; scientificCalc.DefineFunction("sqrt(x) = x^0.5"); scientificCalc.DefineVariable("pi = 3.14159"); // Setup a "Financial" configuration uCalc financialCalc; financialCalc.DefineFunction("tax(amount, rate) = amount * (rate/100)"); // Set the scientific calculator as the default scientificCalc.IsDefault(true); cout << "Current default is scientific? " << tf(scientificCalc.IsDefault()) << endl; // Components that rely on the default instance now use the scientific setup. uCalc::Expression expr1 = "2 * pi"; cout << "2 * pi = " << expr1.Evaluate() << endl; // Now, switch the default to the financial calculator financialCalc.IsDefault(true); cout << "Current default is scientific? " << tf(scientificCalc.IsDefault()) << endl; // Should be false now cout << "Current default is financial? " << tf(financialCalc.IsDefault()) << endl; // New components will use the financial setup. uCalc::Expression expr2 = "tax(50000, 20)"; cout << "Tax on 50000 at 20% = " << expr2.Evaluate() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Setup a "Scientific" configuration
Dim scientificCalc As New uCalc()
scientificCalc.DefineFunction("sqrt(x) = x^0.5")
scientificCalc.DefineVariable("pi = 3.14159")
'// Setup a "Financial" configuration
Dim financialCalc As New uCalc()
financialCalc.DefineFunction("tax(amount, rate) = amount * (rate/100)")
'// Set the scientific calculator as the default
scientificCalc.IsDefault = true
Console.WriteLine($"Current default is scientific? {scientificCalc.IsDefault}")
'// Components that rely on the default instance now use the scientific setup.
Dim expr1 As uCalc.Expression = "2 * pi"
Console.WriteLine($"2 * pi = {expr1.Evaluate()}")
'// Now, switch the default to the financial calculator
financialCalc.IsDefault = true
Console.WriteLine($"Current default is scientific? {scientificCalc.IsDefault}") '// Should be false now
Console.WriteLine($"Current default is financial? {financialCalc.IsDefault}")
'// New components will use the financial setup.
Dim expr2 As uCalc.Expression = "tax(50000, 20)"
Console.WriteLine($"Tax on 50000 at 20% = {expr2.Evaluate()}")
End Sub
End Module
Current default is scientific? True
2 * pi = 6.28318
Current default is scientific? False
Current default is financial? True
Tax on 50000 at 20% = 10000 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Setup a "Scientific" configuration Dim scientificCalc As New uCalc() scientificCalc.DefineFunction("sqrt(x) = x^0.5") scientificCalc.DefineVariable("pi = 3.14159") '// Setup a "Financial" configuration Dim financialCalc As New uCalc() financialCalc.DefineFunction("tax(amount, rate) = amount * (rate/100)") '// Set the scientific calculator as the default scientificCalc.IsDefault = true Console.WriteLine($"Current default is scientific? {scientificCalc.IsDefault}") '// Components that rely on the default instance now use the scientific setup. Dim expr1 As uCalc.Expression = "2 * pi" Console.WriteLine($"2 * pi = {expr1.Evaluate()}") '// Now, switch the default to the financial calculator financialCalc.IsDefault = true Console.WriteLine($"Current default is scientific? {scientificCalc.IsDefault}") '// Should be false now Console.WriteLine($"Current default is financial? {financialCalc.IsDefault}") '// New components will use the financial setup. Dim expr2 As uCalc.Expression = "tax(50000, 20)" Console.WriteLine($"Tax on 50000 at 20% = {expr2.Evaluate()}") End Sub End Module
ID: 368
using uCalcSoftware;
var uc = new uCalc();
// Define a variable in the original default to distinguish it.
// Note: This variable won't exist in the implicit 'uc' instance.
uCalc.DefaultInstance.DefineVariable("id='Original'");
Console.WriteLine($"Initial default: {uCalc.DefaultInstance.EvalStr("id")}");
var ucA = new uCalc();
ucA.DefineVariable("id='A'");
ucA.IsDefault = true; // Default stack: [Original, A]
Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}");
var ucB = new uCalc();
ucB.DefineVariable("id='B'");
ucB.IsDefault = true; // Default stack: [Original, A, B]
Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}");
var ucC = new uCalc();
ucC.DefineVariable("id='C'");
ucC.IsDefault = true; // Default stack: [Original, A, B, C]
Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}");
Console.WriteLine("--- Unsetting instances ---");
// Unset B. The default should remain C.
ucB.IsDefault = false;
Console.WriteLine($"After unsetting B, current default: {uCalc.DefaultInstance.EvalStr("id")}");
// Unset C. The default should revert to A.
ucC.IsDefault = false;
Console.WriteLine($"After unsetting C, current default: {uCalc.DefaultInstance.EvalStr("id")}");
// Unset A. Reverts to the original default.
ucA.IsDefault = false;
Console.WriteLine($"After unsetting A, current default: {uCalc.DefaultInstance.EvalStr("id")}");
Initial default: Original
Current default: A
Current default: B
Current default: C
--- Unsetting instances ---
After unsetting B, current default: C
After unsetting C, current default: A
After unsetting A, current default: Original using uCalcSoftware; var uc = new uCalc(); // Define a variable in the original default to distinguish it. // Note: This variable won't exist in the implicit 'uc' instance. uCalc.DefaultInstance.DefineVariable("id='Original'"); Console.WriteLine($"Initial default: {uCalc.DefaultInstance.EvalStr("id")}"); var ucA = new uCalc(); ucA.DefineVariable("id='A'"); ucA.IsDefault = true; // Default stack: [Original, A] Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}"); var ucB = new uCalc(); ucB.DefineVariable("id='B'"); ucB.IsDefault = true; // Default stack: [Original, A, B] Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}"); var ucC = new uCalc(); ucC.DefineVariable("id='C'"); ucC.IsDefault = true; // Default stack: [Original, A, B, C] Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}"); Console.WriteLine("--- Unsetting instances ---"); // Unset B. The default should remain C. ucB.IsDefault = false; Console.WriteLine($"After unsetting B, current default: {uCalc.DefaultInstance.EvalStr("id")}"); // Unset C. The default should revert to A. ucC.IsDefault = false; Console.WriteLine($"After unsetting C, current default: {uCalc.DefaultInstance.EvalStr("id")}"); // Unset A. Reverts to the original default. ucA.IsDefault = false; Console.WriteLine($"After unsetting A, current default: {uCalc.DefaultInstance.EvalStr("id")}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// Define a variable in the original default to distinguish it.
// Note: This variable won't exist in the implicit 'uc' instance.
uCalc::DefaultInstance().DefineVariable("id='Original'");
cout << "Initial default: " << uCalc::DefaultInstance().EvalStr("id") << endl;
uCalc ucA;
ucA.DefineVariable("id='A'");
ucA.IsDefault(true); // Default stack: [Original, A]
cout << "Current default: " << uCalc::DefaultInstance().EvalStr("id") << endl;
uCalc ucB;
ucB.DefineVariable("id='B'");
ucB.IsDefault(true); // Default stack: [Original, A, B]
cout << "Current default: " << uCalc::DefaultInstance().EvalStr("id") << endl;
uCalc ucC;
ucC.DefineVariable("id='C'");
ucC.IsDefault(true); // Default stack: [Original, A, B, C]
cout << "Current default: " << uCalc::DefaultInstance().EvalStr("id") << endl;
cout << "--- Unsetting instances ---" << endl;
// Unset B. The default should remain C.
ucB.IsDefault(false);
cout << "After unsetting B, current default: " << uCalc::DefaultInstance().EvalStr("id") << endl;
// Unset C. The default should revert to A.
ucC.IsDefault(false);
cout << "After unsetting C, current default: " << uCalc::DefaultInstance().EvalStr("id") << endl;
// Unset A. Reverts to the original default.
ucA.IsDefault(false);
cout << "After unsetting A, current default: " << uCalc::DefaultInstance().EvalStr("id") << endl;
}
Initial default: Original
Current default: A
Current default: B
Current default: C
--- Unsetting instances ---
After unsetting B, current default: C
After unsetting C, current default: A
After unsetting A, current default: Original #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // Define a variable in the original default to distinguish it. // Note: This variable won't exist in the implicit 'uc' instance. uCalc::DefaultInstance().DefineVariable("id='Original'"); cout << "Initial default: " << uCalc::DefaultInstance().EvalStr("id") << endl; uCalc ucA; ucA.DefineVariable("id='A'"); ucA.IsDefault(true); // Default stack: [Original, A] cout << "Current default: " << uCalc::DefaultInstance().EvalStr("id") << endl; uCalc ucB; ucB.DefineVariable("id='B'"); ucB.IsDefault(true); // Default stack: [Original, A, B] cout << "Current default: " << uCalc::DefaultInstance().EvalStr("id") << endl; uCalc ucC; ucC.DefineVariable("id='C'"); ucC.IsDefault(true); // Default stack: [Original, A, B, C] cout << "Current default: " << uCalc::DefaultInstance().EvalStr("id") << endl; cout << "--- Unsetting instances ---" << endl; // Unset B. The default should remain C. ucB.IsDefault(false); cout << "After unsetting B, current default: " << uCalc::DefaultInstance().EvalStr("id") << endl; // Unset C. The default should revert to A. ucC.IsDefault(false); cout << "After unsetting C, current default: " << uCalc::DefaultInstance().EvalStr("id") << endl; // Unset A. Reverts to the original default. ucA.IsDefault(false); cout << "After unsetting A, current default: " << uCalc::DefaultInstance().EvalStr("id") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// Define a variable in the original default to distinguish it.
'// Note: This variable won't exist in the implicit 'uc' instance.
uCalc.DefaultInstance.DefineVariable("id='Original'")
Console.WriteLine($"Initial default: {uCalc.DefaultInstance.EvalStr("id")}")
Dim ucA As New uCalc()
ucA.DefineVariable("id='A'")
ucA.IsDefault = true '// Default stack: [Original, A]
Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}")
Dim ucB As New uCalc()
ucB.DefineVariable("id='B'")
ucB.IsDefault = true '// Default stack: [Original, A, B]
Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}")
Dim ucC As New uCalc()
ucC.DefineVariable("id='C'")
ucC.IsDefault = true '// Default stack: [Original, A, B, C]
Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}")
Console.WriteLine("--- Unsetting instances ---")
'// Unset B. The default should remain C.
ucB.IsDefault = false
Console.WriteLine($"After unsetting B, current default: {uCalc.DefaultInstance.EvalStr("id")}")
'// Unset C. The default should revert to A.
ucC.IsDefault = false
Console.WriteLine($"After unsetting C, current default: {uCalc.DefaultInstance.EvalStr("id")}")
'// Unset A. Reverts to the original default.
ucA.IsDefault = false
Console.WriteLine($"After unsetting A, current default: {uCalc.DefaultInstance.EvalStr("id")}")
End Sub
End Module
Initial default: Original
Current default: A
Current default: B
Current default: C
--- Unsetting instances ---
After unsetting B, current default: C
After unsetting C, current default: A
After unsetting A, current default: Original Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// Define a variable in the original default to distinguish it. '// Note: This variable won't exist in the implicit 'uc' instance. uCalc.DefaultInstance.DefineVariable("id='Original'") Console.WriteLine($"Initial default: {uCalc.DefaultInstance.EvalStr("id")}") Dim ucA As New uCalc() ucA.DefineVariable("id='A'") ucA.IsDefault = true '// Default stack: [Original, A] Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}") Dim ucB As New uCalc() ucB.DefineVariable("id='B'") ucB.IsDefault = true '// Default stack: [Original, A, B] Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}") Dim ucC As New uCalc() ucC.DefineVariable("id='C'") ucC.IsDefault = true '// Default stack: [Original, A, B, C] Console.WriteLine($"Current default: {uCalc.DefaultInstance.EvalStr("id")}") Console.WriteLine("--- Unsetting instances ---") '// Unset B. The default should remain C. ucB.IsDefault = false Console.WriteLine($"After unsetting B, current default: {uCalc.DefaultInstance.EvalStr("id")}") '// Unset C. The default should revert to A. ucC.IsDefault = false Console.WriteLine($"After unsetting C, current default: {uCalc.DefaultInstance.EvalStr("id")}") '// Unset A. Reverts to the original default. ucA.IsDefault = false Console.WriteLine($"After unsetting A, current default: {uCalc.DefaultInstance.EvalStr("id")}") End Sub End Module
ID: 75
using uCalcSoftware;
var uc = new uCalc();
var Status = uc.DefineVariable("Status As Bool");
Console.WriteLine(Status.ValueBool());
var MyuCalc = new uCalc();
Status.ValueBool(MyuCalc.IsDefault);
Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'"));
MyuCalc.IsDefault = true;
Status.ValueBool(MyuCalc.IsDefault);
Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'"));
False
MyuCalc is the current default? false
MyuCalc is the current default? true using uCalcSoftware; var uc = new uCalc(); var Status = uc.DefineVariable("Status As Bool"); Console.WriteLine(Status.ValueBool()); var MyuCalc = new uCalc(); Status.ValueBool(MyuCalc.IsDefault); Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'")); MyuCalc.IsDefault = true; Status.ValueBool(MyuCalc.IsDefault); Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
auto Status = uc.DefineVariable("Status As Bool");
cout << tf(Status.ValueBool()) << endl;
uCalc MyuCalc;
Status.ValueBool(MyuCalc.IsDefault());
cout << uc.EvalStr("$'MyuCalc is the current default? {Status}'") << endl;
MyuCalc.IsDefault(true);
Status.ValueBool(MyuCalc.IsDefault());
cout << uc.EvalStr("$'MyuCalc is the current default? {Status}'") << endl;
}
False
MyuCalc is the current default? false
MyuCalc is the current default? true #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; auto Status = uc.DefineVariable("Status As Bool"); cout << tf(Status.ValueBool()) << endl; uCalc MyuCalc; Status.ValueBool(MyuCalc.IsDefault()); cout << uc.EvalStr("$'MyuCalc is the current default? {Status}'") << endl; MyuCalc.IsDefault(true); Status.ValueBool(MyuCalc.IsDefault()); cout << uc.EvalStr("$'MyuCalc is the current default? {Status}'") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim Status = uc.DefineVariable("Status As Bool")
Console.WriteLine(Status.ValueBool())
Dim MyuCalc As New uCalc()
Status.ValueBool(MyuCalc.IsDefault)
Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'"))
MyuCalc.IsDefault = true
Status.ValueBool(MyuCalc.IsDefault)
Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'"))
End Sub
End Module
False
MyuCalc is the current default? false
MyuCalc is the current default? true Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim Status = uc.DefineVariable("Status As Bool") Console.WriteLine(Status.ValueBool()) Dim MyuCalc As New uCalc() Status.ValueBool(MyuCalc.IsDefault) Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'")) MyuCalc.IsDefault = true Status.ValueBool(MyuCalc.IsDefault) Console.WriteLine(uc.EvalStr("$'MyuCalc is the current default? {Status}'")) End Sub End Module
ID: 76
using uCalcSoftware;
var uc = new uCalc();
var uCalcA = new uCalc();
var uCalcB = new uCalc();
var uCalcC = new uCalc();
uCalcA.DefineVariable("MyVar = 'I was cloned from uCalcA'");
uCalcB.DefineVariable("MyVar = 'I was cloned from uCalcB'");
uCalcC.DefineVariable("MyVar = 'I was cloned from uCalcC'");
uCalcA.IsDefault = true;
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"));
uCalcB.IsDefault = true;
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"));
uCalcC.IsDefault = true;
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"));
Console.WriteLine("---");
// Now unsetting uCalc objects as default
uCalcC.IsDefault = false;
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"));
uCalcB.IsDefault = false;
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"));
uCalcA.IsDefault = false;
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"));
I was cloned from uCalcA
I was cloned from uCalcB
I was cloned from uCalcC
---
I was cloned from uCalcB
I was cloned from uCalcA
Undefined identifier using uCalcSoftware; var uc = new uCalc(); var uCalcA = new uCalc(); var uCalcB = new uCalc(); var uCalcC = new uCalc(); uCalcA.DefineVariable("MyVar = 'I was cloned from uCalcA'"); uCalcB.DefineVariable("MyVar = 'I was cloned from uCalcB'"); uCalcC.DefineVariable("MyVar = 'I was cloned from uCalcC'"); uCalcA.IsDefault = true; Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")); uCalcB.IsDefault = true; Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")); uCalcC.IsDefault = true; Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")); Console.WriteLine("---"); // Now unsetting uCalc objects as default uCalcC.IsDefault = false; Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")); uCalcB.IsDefault = false; Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")); uCalcA.IsDefault = false; Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc uCalcA;
uCalc uCalcB;
uCalc uCalcC;
uCalcA.DefineVariable("MyVar = 'I was cloned from uCalcA'");
uCalcB.DefineVariable("MyVar = 'I was cloned from uCalcB'");
uCalcC.DefineVariable("MyVar = 'I was cloned from uCalcC'");
uCalcA.IsDefault(true);
cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl;
uCalcB.IsDefault(true);
cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl;
uCalcC.IsDefault(true);
cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl;
cout << "---" << endl;
// Now unsetting uCalc objects as default
uCalcC.IsDefault(false);
cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl;
uCalcB.IsDefault(false);
cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl;
uCalcA.IsDefault(false);
cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl;
}
I was cloned from uCalcA
I was cloned from uCalcB
I was cloned from uCalcC
---
I was cloned from uCalcB
I was cloned from uCalcA
Undefined identifier #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc uCalcA; uCalc uCalcB; uCalc uCalcC; uCalcA.DefineVariable("MyVar = 'I was cloned from uCalcA'"); uCalcB.DefineVariable("MyVar = 'I was cloned from uCalcB'"); uCalcC.DefineVariable("MyVar = 'I was cloned from uCalcC'"); uCalcA.IsDefault(true); cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl; uCalcB.IsDefault(true); cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl; uCalcC.IsDefault(true); cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl; cout << "---" << endl; // Now unsetting uCalc objects as default uCalcC.IsDefault(false); cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl; uCalcB.IsDefault(false); cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl; uCalcA.IsDefault(false); cout << uCalc::DefaultInstance().EvalStr("MyVar") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim uCalcA As New uCalc()
Dim uCalcB As New uCalc()
Dim uCalcC As New uCalc()
uCalcA.DefineVariable("MyVar = 'I was cloned from uCalcA'")
uCalcB.DefineVariable("MyVar = 'I was cloned from uCalcB'")
uCalcC.DefineVariable("MyVar = 'I was cloned from uCalcC'")
uCalcA.IsDefault = true
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"))
uCalcB.IsDefault = true
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"))
uCalcC.IsDefault = true
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"))
Console.WriteLine("---")
'// Now unsetting uCalc objects as default
uCalcC.IsDefault = false
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"))
uCalcB.IsDefault = false
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"))
uCalcA.IsDefault = false
Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar"))
End Sub
End Module
I was cloned from uCalcA
I was cloned from uCalcB
I was cloned from uCalcC
---
I was cloned from uCalcB
I was cloned from uCalcA
Undefined identifier Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim uCalcA As New uCalc() Dim uCalcB As New uCalc() Dim uCalcC As New uCalc() uCalcA.DefineVariable("MyVar = 'I was cloned from uCalcA'") uCalcB.DefineVariable("MyVar = 'I was cloned from uCalcB'") uCalcC.DefineVariable("MyVar = 'I was cloned from uCalcC'") uCalcA.IsDefault = true Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")) uCalcB.IsDefault = true Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")) uCalcC.IsDefault = true Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")) Console.WriteLine("---") '// Now unsetting uCalc objects as default uCalcC.IsDefault = false Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")) uCalcB.IsDefault = false Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")) uCalcA.IsDefault = false Console.WriteLine(uCalc.DefaultInstance.EvalStr("MyVar")) End Sub End Module
ID: 60
using uCalcSoftware;
var uc = new uCalc();
uCalc.DefaultInstance.DefineVariable("instance = 'original default'");
var ucB = new uCalc();
var ucC = new uCalc();
var ucD = new uCalc();
ucB.Eval("instance = 'B derived from -> ' + instance");
ucC.Eval("instance = 'C derived from -> ' + instance");
ucD.Eval("instance = 'D derived from -> ' + instance");
ucC.IsDefault = true;
var ucE = new uCalc();
ucE.Eval("instance = 'E derived from -> ' + instance");
Console.WriteLine(uCalc.DefaultInstance.EvalStr("'Default: ' + instance"));
Console.WriteLine(uc.EvalStr("instance")); // Note: this is not, nor was the default
Console.WriteLine(ucB.EvalStr("instance"));
Console.WriteLine(ucC.EvalStr("instance"));
Console.WriteLine(ucD.EvalStr("instance"));
Console.WriteLine(ucE.EvalStr("instance"));
// Note: Unlike this example, it is generally best to always
// create a new instance first and then set it as default
Default: C derived from -> original default
Undefined identifier
B derived from -> original default
C derived from -> original default
D derived from -> original default
E derived from -> C derived from -> original default using uCalcSoftware; var uc = new uCalc(); uCalc.DefaultInstance.DefineVariable("instance = 'original default'"); var ucB = new uCalc(); var ucC = new uCalc(); var ucD = new uCalc(); ucB.Eval("instance = 'B derived from -> ' + instance"); ucC.Eval("instance = 'C derived from -> ' + instance"); ucD.Eval("instance = 'D derived from -> ' + instance"); ucC.IsDefault = true; var ucE = new uCalc(); ucE.Eval("instance = 'E derived from -> ' + instance"); Console.WriteLine(uCalc.DefaultInstance.EvalStr("'Default: ' + instance")); Console.WriteLine(uc.EvalStr("instance")); // Note: this is not, nor was the default Console.WriteLine(ucB.EvalStr("instance")); Console.WriteLine(ucC.EvalStr("instance")); Console.WriteLine(ucD.EvalStr("instance")); Console.WriteLine(ucE.EvalStr("instance")); // Note: Unlike this example, it is generally best to always // create a new instance first and then set it as default
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::DefaultInstance().DefineVariable("instance = 'original default'");
uCalc ucB;
uCalc ucC;
uCalc ucD;
ucB.Eval("instance = 'B derived from -> ' + instance");
ucC.Eval("instance = 'C derived from -> ' + instance");
ucD.Eval("instance = 'D derived from -> ' + instance");
ucC.IsDefault(true);
uCalc ucE;
ucE.Eval("instance = 'E derived from -> ' + instance");
cout << uCalc::DefaultInstance().EvalStr("'Default: ' + instance") << endl;
cout << uc.EvalStr("instance") << endl; // Note: this is not, nor was the default
cout << ucB.EvalStr("instance") << endl;
cout << ucC.EvalStr("instance") << endl;
cout << ucD.EvalStr("instance") << endl;
cout << ucE.EvalStr("instance") << endl;
// Note: Unlike this example, it is generally best to always
// create a new instance first and then set it as default
}
Default: C derived from -> original default
Undefined identifier
B derived from -> original default
C derived from -> original default
D derived from -> original default
E derived from -> C derived from -> original default #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::DefaultInstance().DefineVariable("instance = 'original default'"); uCalc ucB; uCalc ucC; uCalc ucD; ucB.Eval("instance = 'B derived from -> ' + instance"); ucC.Eval("instance = 'C derived from -> ' + instance"); ucD.Eval("instance = 'D derived from -> ' + instance"); ucC.IsDefault(true); uCalc ucE; ucE.Eval("instance = 'E derived from -> ' + instance"); cout << uCalc::DefaultInstance().EvalStr("'Default: ' + instance") << endl; cout << uc.EvalStr("instance") << endl; // Note: this is not, nor was the default cout << ucB.EvalStr("instance") << endl; cout << ucC.EvalStr("instance") << endl; cout << ucD.EvalStr("instance") << endl; cout << ucE.EvalStr("instance") << endl; // Note: Unlike this example, it is generally best to always // create a new instance first and then set it as default }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
uCalc.DefaultInstance.DefineVariable("instance = 'original default'")
Dim ucB As New uCalc()
Dim ucC As New uCalc()
Dim ucD As New uCalc()
ucB.Eval("instance = 'B derived from -> ' + instance")
ucC.Eval("instance = 'C derived from -> ' + instance")
ucD.Eval("instance = 'D derived from -> ' + instance")
ucC.IsDefault = true
Dim ucE As New uCalc()
ucE.Eval("instance = 'E derived from -> ' + instance")
Console.WriteLine(uCalc.DefaultInstance.EvalStr("'Default: ' + instance"))
Console.WriteLine(uc.EvalStr("instance")) '// Note: this is not, nor was the default
Console.WriteLine(ucB.EvalStr("instance"))
Console.WriteLine(ucC.EvalStr("instance"))
Console.WriteLine(ucD.EvalStr("instance"))
Console.WriteLine(ucE.EvalStr("instance"))
'// Note: Unlike this example, it is generally best to always
'// create a new instance first and then set it as default
End Sub
End Module
Default: C derived from -> original default
Undefined identifier
B derived from -> original default
C derived from -> original default
D derived from -> original default
E derived from -> C derived from -> original default Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() uCalc.DefaultInstance.DefineVariable("instance = 'original default'") Dim ucB As New uCalc() Dim ucC As New uCalc() Dim ucD As New uCalc() ucB.Eval("instance = 'B derived from -> ' + instance") ucC.Eval("instance = 'C derived from -> ' + instance") ucD.Eval("instance = 'D derived from -> ' + instance") ucC.IsDefault = true Dim ucE As New uCalc() ucE.Eval("instance = 'E derived from -> ' + instance") Console.WriteLine(uCalc.DefaultInstance.EvalStr("'Default: ' + instance")) Console.WriteLine(uc.EvalStr("instance")) '// Note: this is not, nor was the default Console.WriteLine(ucB.EvalStr("instance")) Console.WriteLine(ucC.EvalStr("instance")) Console.WriteLine(ucD.EvalStr("instance")) Console.WriteLine(ucE.EvalStr("instance")) '// Note: Unlike this example, it is generally best to always '// create a new instance first and then set it as default End Sub End Module
ID: 61
using uCalcSoftware;
var uc = new uCalc();
uCalc.DefaultInstance.DefineVariable("val = 'original default'");
Console.WriteLine(uCalc.DefaultInstance.EvalStr("val"));
uc.DefineVariable("val = 'uc'");
uc.IsDefault = true;
Console.WriteLine(uCalc.DefaultInstance.EvalStr("val"));
var ucB = new uCalc();
ucB.DefineVariable("val = 'ucB'");
ucB.IsDefault = true;
Console.WriteLine(uCalc.DefaultInstance.EvalStr("val"));
var ucC = new uCalc();
ucC.DefineVariable("val = 'ucC'");
ucC.IsDefault = true;
Console.WriteLine(uCalc.DefaultInstance.EvalStr("val"));
uCalc.DefaultClear();
// The original unnamed default instance is reset so user variable val no longer exists
Console.WriteLine(uCalc.DefaultInstance.EvalStr("val"));
// The other instances are removed from Default list but remain active
Console.WriteLine(uc.EvalStr("val"));
Console.WriteLine(ucB.EvalStr("val"));
Console.WriteLine(ucC.EvalStr("val"));
original default
uc
ucB
ucC
Undefined identifier
uc
ucB
ucC using uCalcSoftware; var uc = new uCalc(); uCalc.DefaultInstance.DefineVariable("val = 'original default'"); Console.WriteLine(uCalc.DefaultInstance.EvalStr("val")); uc.DefineVariable("val = 'uc'"); uc.IsDefault = true; Console.WriteLine(uCalc.DefaultInstance.EvalStr("val")); var ucB = new uCalc(); ucB.DefineVariable("val = 'ucB'"); ucB.IsDefault = true; Console.WriteLine(uCalc.DefaultInstance.EvalStr("val")); var ucC = new uCalc(); ucC.DefineVariable("val = 'ucC'"); ucC.IsDefault = true; Console.WriteLine(uCalc.DefaultInstance.EvalStr("val")); uCalc.DefaultClear(); // The original unnamed default instance is reset so user variable val no longer exists Console.WriteLine(uCalc.DefaultInstance.EvalStr("val")); // The other instances are removed from Default list but remain active Console.WriteLine(uc.EvalStr("val")); Console.WriteLine(ucB.EvalStr("val")); Console.WriteLine(ucC.EvalStr("val"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::DefaultInstance().DefineVariable("val = 'original default'");
cout << uCalc::DefaultInstance().EvalStr("val") << endl;
uc.DefineVariable("val = 'uc'");
uc.IsDefault(true);
cout << uCalc::DefaultInstance().EvalStr("val") << endl;
uCalc ucB;
ucB.DefineVariable("val = 'ucB'");
ucB.IsDefault(true);
cout << uCalc::DefaultInstance().EvalStr("val") << endl;
uCalc ucC;
ucC.DefineVariable("val = 'ucC'");
ucC.IsDefault(true);
cout << uCalc::DefaultInstance().EvalStr("val") << endl;
uCalc::DefaultClear();
// The original unnamed default instance is reset so user variable val no longer exists
cout << uCalc::DefaultInstance().EvalStr("val") << endl;
// The other instances are removed from Default list but remain active
cout << uc.EvalStr("val") << endl;
cout << ucB.EvalStr("val") << endl;
cout << ucC.EvalStr("val") << endl;
}
original default
uc
ucB
ucC
Undefined identifier
uc
ucB
ucC #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::DefaultInstance().DefineVariable("val = 'original default'"); cout << uCalc::DefaultInstance().EvalStr("val") << endl; uc.DefineVariable("val = 'uc'"); uc.IsDefault(true); cout << uCalc::DefaultInstance().EvalStr("val") << endl; uCalc ucB; ucB.DefineVariable("val = 'ucB'"); ucB.IsDefault(true); cout << uCalc::DefaultInstance().EvalStr("val") << endl; uCalc ucC; ucC.DefineVariable("val = 'ucC'"); ucC.IsDefault(true); cout << uCalc::DefaultInstance().EvalStr("val") << endl; uCalc::DefaultClear(); // The original unnamed default instance is reset so user variable val no longer exists cout << uCalc::DefaultInstance().EvalStr("val") << endl; // The other instances are removed from Default list but remain active cout << uc.EvalStr("val") << endl; cout << ucB.EvalStr("val") << endl; cout << ucC.EvalStr("val") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
uCalc.DefaultInstance.DefineVariable("val = 'original default'")
Console.WriteLine(uCalc.DefaultInstance.EvalStr("val"))
uc.DefineVariable("val = 'uc'")
uc.IsDefault = true
Console.WriteLine(uCalc.DefaultInstance.EvalStr("val"))
Dim ucB As New uCalc()
ucB.DefineVariable("val = 'ucB'")
ucB.IsDefault = true
Console.WriteLine(uCalc.DefaultInstance.EvalStr("val"))
Dim ucC As New uCalc()
ucC.DefineVariable("val = 'ucC'")
ucC.IsDefault = true
Console.WriteLine(uCalc.DefaultInstance.EvalStr("val"))
uCalc.DefaultClear()
'// The original unnamed default instance is reset so user variable val no longer exists
Console.WriteLine(uCalc.DefaultInstance.EvalStr("val"))
'// The other instances are removed from Default list but remain active
Console.WriteLine(uc.EvalStr("val"))
Console.WriteLine(ucB.EvalStr("val"))
Console.WriteLine(ucC.EvalStr("val"))
End Sub
End Module
original default
uc
ucB
ucC
Undefined identifier
uc
ucB
ucC Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() uCalc.DefaultInstance.DefineVariable("val = 'original default'") Console.WriteLine(uCalc.DefaultInstance.EvalStr("val")) uc.DefineVariable("val = 'uc'") uc.IsDefault = true Console.WriteLine(uCalc.DefaultInstance.EvalStr("val")) Dim ucB As New uCalc() ucB.DefineVariable("val = 'ucB'") ucB.IsDefault = true Console.WriteLine(uCalc.DefaultInstance.EvalStr("val")) Dim ucC As New uCalc() ucC.DefineVariable("val = 'ucC'") ucC.IsDefault = true Console.WriteLine(uCalc.DefaultInstance.EvalStr("val")) uCalc.DefaultClear() '// The original unnamed default instance is reset so user variable val no longer exists Console.WriteLine(uCalc.DefaultInstance.EvalStr("val")) '// The other instances are removed from Default list but remain active Console.WriteLine(uc.EvalStr("val")) Console.WriteLine(ucB.EvalStr("val")) Console.WriteLine(ucC.EvalStr("val")) End Sub End Module
ID: 79
using uCalcSoftware;
var uc = new uCalc();
var ucB = new uCalc();
uc.DefineVariable("x = 111");
ucB.DefineVariable("x = 222");
Console.WriteLine("--- using 'uc' as default ---");
uc.IsDefault = true;
uCalc.String MyString = "The variable value is: x";
Console.WriteLine(MyString.Replace("x", "{@Eval: x}"));
uCalc.Expression MyExpression = "x * 1000";
Console.WriteLine(MyExpression.Evaluate());
var MyTransformer = new uCalc.Transformer();
MyTransformer.Text = "Value is: x";
MyTransformer.FromTo("x", "{@Eval: x}");
Console.WriteLine(MyTransformer.Transform());
Console.WriteLine("--- using 'ucB' as default ---");
ucB.IsDefault = true;
uCalc.String MyStringB = "The variable value is: x";
Console.WriteLine(MyStringB.Replace("x", "{@Eval: x}"));
uCalc.Expression MyExpressionB = "x * 1000";
Console.WriteLine(MyExpressionB.Evaluate());
var MyTransformerB = new uCalc.Transformer();
MyTransformerB.Str("Value is: x");
MyTransformerB.FromTo("x", "{@Eval: x}");
Console.WriteLine(MyTransformerB.Transform());
--- using 'uc' as default ---
The variable value is: 111
111000
Value is: 111
--- using 'ucB' as default ---
The variable value is: 222
222000
Value is: 222 using uCalcSoftware; var uc = new uCalc(); var ucB = new uCalc(); uc.DefineVariable("x = 111"); ucB.DefineVariable("x = 222"); Console.WriteLine("--- using 'uc' as default ---"); uc.IsDefault = true; uCalc.String MyString = "The variable value is: x"; Console.WriteLine(MyString.Replace("x", "{@Eval: x}")); uCalc.Expression MyExpression = "x * 1000"; Console.WriteLine(MyExpression.Evaluate()); var MyTransformer = new uCalc.Transformer(); MyTransformer.Text = "Value is: x"; MyTransformer.FromTo("x", "{@Eval: x}"); Console.WriteLine(MyTransformer.Transform()); Console.WriteLine("--- using 'ucB' as default ---"); ucB.IsDefault = true; uCalc.String MyStringB = "The variable value is: x"; Console.WriteLine(MyStringB.Replace("x", "{@Eval: x}")); uCalc.Expression MyExpressionB = "x * 1000"; Console.WriteLine(MyExpressionB.Evaluate()); var MyTransformerB = new uCalc.Transformer(); MyTransformerB.Str("Value is: x"); MyTransformerB.FromTo("x", "{@Eval: x}"); Console.WriteLine(MyTransformerB.Transform());
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc ucB;
uc.DefineVariable("x = 111");
ucB.DefineVariable("x = 222");
cout << "--- using 'uc' as default ---" << endl;
uc.IsDefault(true);
uCalc::String MyString = "The variable value is: x";
cout << MyString.Replace("x", "{@Eval: x}") << endl;
uCalc::Expression MyExpression = "x * 1000";
cout << MyExpression.Evaluate() << endl;
uCalc::Transformer MyTransformer;
MyTransformer.Text("Value is: x");
MyTransformer.FromTo("x", "{@Eval: x}");
cout << MyTransformer.Transform() << endl;
cout << "--- using 'ucB' as default ---" << endl;
ucB.IsDefault(true);
uCalc::String MyStringB = "The variable value is: x";
cout << MyStringB.Replace("x", "{@Eval: x}") << endl;
uCalc::Expression MyExpressionB = "x * 1000";
cout << MyExpressionB.Evaluate() << endl;
uCalc::Transformer MyTransformerB;
MyTransformerB.Str("Value is: x");
MyTransformerB.FromTo("x", "{@Eval: x}");
cout << MyTransformerB.Transform() << endl;
}
--- using 'uc' as default ---
The variable value is: 111
111000
Value is: 111
--- using 'ucB' as default ---
The variable value is: 222
222000
Value is: 222 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc ucB; uc.DefineVariable("x = 111"); ucB.DefineVariable("x = 222"); cout << "--- using 'uc' as default ---" << endl; uc.IsDefault(true); uCalc::String MyString = "The variable value is: x"; cout << MyString.Replace("x", "{@Eval: x}") << endl; uCalc::Expression MyExpression = "x * 1000"; cout << MyExpression.Evaluate() << endl; uCalc::Transformer MyTransformer; MyTransformer.Text("Value is: x"); MyTransformer.FromTo("x", "{@Eval: x}"); cout << MyTransformer.Transform() << endl; cout << "--- using 'ucB' as default ---" << endl; ucB.IsDefault(true); uCalc::String MyStringB = "The variable value is: x"; cout << MyStringB.Replace("x", "{@Eval: x}") << endl; uCalc::Expression MyExpressionB = "x * 1000"; cout << MyExpressionB.Evaluate() << endl; uCalc::Transformer MyTransformerB; MyTransformerB.Str("Value is: x"); MyTransformerB.FromTo("x", "{@Eval: x}"); cout << MyTransformerB.Transform() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim ucB As New uCalc()
uc.DefineVariable("x = 111")
ucB.DefineVariable("x = 222")
Console.WriteLine("--- using 'uc' as default ---")
uc.IsDefault = true
Dim MyString As uCalc.String = "The variable value is: x"
Console.WriteLine(MyString.Replace("x", "{@Eval: x}"))
Dim MyExpression As uCalc.Expression = "x * 1000"
Console.WriteLine(MyExpression.Evaluate())
Dim MyTransformer As New uCalc.Transformer()
MyTransformer.Text = "Value is: x"
MyTransformer.FromTo("x", "{@Eval: x}")
Console.WriteLine(MyTransformer.Transform())
Console.WriteLine("--- using 'ucB' as default ---")
ucB.IsDefault = true
Dim MyStringB As uCalc.String = "The variable value is: x"
Console.WriteLine(MyStringB.Replace("x", "{@Eval: x}"))
Dim MyExpressionB As uCalc.Expression = "x * 1000"
Console.WriteLine(MyExpressionB.Evaluate())
Dim MyTransformerB As New uCalc.Transformer()
MyTransformerB.Str("Value is: x")
MyTransformerB.FromTo("x", "{@Eval: x}")
Console.WriteLine(MyTransformerB.Transform())
End Sub
End Module
--- using 'uc' as default ---
The variable value is: 111
111000
Value is: 111
--- using 'ucB' as default ---
The variable value is: 222
222000
Value is: 222 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim ucB As New uCalc() uc.DefineVariable("x = 111") ucB.DefineVariable("x = 222") Console.WriteLine("--- using 'uc' as default ---") uc.IsDefault = true Dim MyString As uCalc.String = "The variable value is: x" Console.WriteLine(MyString.Replace("x", "{@Eval: x}")) Dim MyExpression As uCalc.Expression = "x * 1000" Console.WriteLine(MyExpression.Evaluate()) Dim MyTransformer As New uCalc.Transformer() MyTransformer.Text = "Value is: x" MyTransformer.FromTo("x", "{@Eval: x}") Console.WriteLine(MyTransformer.Transform()) Console.WriteLine("--- using 'ucB' as default ---") ucB.IsDefault = true Dim MyStringB As uCalc.String = "The variable value is: x" Console.WriteLine(MyStringB.Replace("x", "{@Eval: x}")) Dim MyExpressionB As uCalc.Expression = "x * 1000" Console.WriteLine(MyExpressionB.Evaluate()) Dim MyTransformerB As New uCalc.Transformer() MyTransformerB.Str("Value is: x") MyTransformerB.FromTo("x", "{@Eval: x}") Console.WriteLine(MyTransformerB.Transform()) End Sub End Module
ID: 271
using uCalcSoftware;
var uc = new uCalc();
// --- Main Application Context ---
// Starting with the 'uc' object as the initial default.
uCalc.DefaultInstance.DefineConstant("PI = 3.14159");
Console.WriteLine($"Initial Count: {uCalc.DefaultCount}");
// --- A Plugin needs a temporary, isolated context ---
using (var moduleCalc = new uCalc()) {
moduleCalc.IsDefault = true; // Push the new instance onto the stack.
Console.WriteLine($"Count after module pushes new default: {uCalc.DefaultCount}");
// The module's context is now active.
// uCalc::DefaultInstance() would now return 'moduleCalc'.
}
// When 'moduleCalc' goes out of scope, it's destroyed and automatically
// removed from the stack, restoring the previous default.
Console.WriteLine($"Count after module instance is disposed: {uCalc.DefaultCount}");
// Verify the original default instance is active again.
var result = uCalc.DefaultInstance.EvalStr("PI");
Console.WriteLine($"Original context restored. PI = {result}");
Initial Count: 1
Count after module pushes new default: 2
Count after module instance is disposed: 1
Original context restored. PI = 3.14159 using uCalcSoftware; var uc = new uCalc(); // --- Main Application Context --- // Starting with the 'uc' object as the initial default. uCalc.DefaultInstance.DefineConstant("PI = 3.14159"); Console.WriteLine($"Initial Count: {uCalc.DefaultCount}"); // --- A Plugin needs a temporary, isolated context --- using (var moduleCalc = new uCalc()) { moduleCalc.IsDefault = true; // Push the new instance onto the stack. Console.WriteLine($"Count after module pushes new default: {uCalc.DefaultCount}"); // The module's context is now active. // uCalc::DefaultInstance() would now return 'moduleCalc'. } // When 'moduleCalc' goes out of scope, it's destroyed and automatically // removed from the stack, restoring the previous default. Console.WriteLine($"Count after module instance is disposed: {uCalc.DefaultCount}"); // Verify the original default instance is active again. var result = uCalc.DefaultInstance.EvalStr("PI"); Console.WriteLine($"Original context restored. PI = {result}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// --- Main Application Context ---
// Starting with the 'uc' object as the initial default.
uCalc::DefaultInstance().DefineConstant("PI = 3.14159");
cout << "Initial Count: " << uCalc::DefaultCount() << endl;
// --- A Plugin needs a temporary, isolated context ---
{
uCalc moduleCalc;
moduleCalc.Owned(); // Causes moduleCalc to be released when it goes out of scope
moduleCalc.IsDefault(true); // Push the new instance onto the stack.
cout << "Count after module pushes new default: " << uCalc::DefaultCount() << endl;
// The module's context is now active.
// uCalc::DefaultInstance() would now return 'moduleCalc'.
}
// When 'moduleCalc' goes out of scope, it's destroyed and automatically
// removed from the stack, restoring the previous default.
cout << "Count after module instance is disposed: " << uCalc::DefaultCount() << endl;
// Verify the original default instance is active again.
auto result = uCalc::DefaultInstance().EvalStr("PI");
cout << "Original context restored. PI = " << result << endl;
}
Initial Count: 1
Count after module pushes new default: 2
Count after module instance is disposed: 1
Original context restored. PI = 3.14159 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // --- Main Application Context --- // Starting with the 'uc' object as the initial default. uCalc::DefaultInstance().DefineConstant("PI = 3.14159"); cout << "Initial Count: " << uCalc::DefaultCount() << endl; // --- A Plugin needs a temporary, isolated context --- { uCalc moduleCalc; moduleCalc.Owned(); // Causes moduleCalc to be released when it goes out of scope moduleCalc.IsDefault(true); // Push the new instance onto the stack. cout << "Count after module pushes new default: " << uCalc::DefaultCount() << endl; // The module's context is now active. // uCalc::DefaultInstance() would now return 'moduleCalc'. } // When 'moduleCalc' goes out of scope, it's destroyed and automatically // removed from the stack, restoring the previous default. cout << "Count after module instance is disposed: " << uCalc::DefaultCount() << endl; // Verify the original default instance is active again. auto result = uCalc::DefaultInstance().EvalStr("PI"); cout << "Original context restored. PI = " << result << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// --- Main Application Context ---
'// Starting with the 'uc' object as the initial default.
uCalc.DefaultInstance.DefineConstant("PI = 3.14159")
Console.WriteLine($"Initial Count: {uCalc.DefaultCount}")
'// --- A Plugin needs a temporary, isolated context ---
Using moduleCalc As New uCalc()
moduleCalc.IsDefault = true '// Push the new instance onto the stack.
Console.WriteLine($"Count after module pushes new default: {uCalc.DefaultCount}")
'// The module's context is now active.
'// uCalc::DefaultInstance() would now return 'moduleCalc'.
End Using
'// When 'moduleCalc' goes out of scope, it's destroyed and automatically
'// removed from the stack, restoring the previous default.
Console.WriteLine($"Count after module instance is disposed: {uCalc.DefaultCount}")
'// Verify the original default instance is active again.
Dim result = uCalc.DefaultInstance.EvalStr("PI")
Console.WriteLine($"Original context restored. PI = {result}")
End Sub
End Module
Initial Count: 1
Count after module pushes new default: 2
Count after module instance is disposed: 1
Original context restored. PI = 3.14159 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// --- Main Application Context --- '// Starting with the 'uc' object as the initial default. uCalc.DefaultInstance.DefineConstant("PI = 3.14159") Console.WriteLine($"Initial Count: {uCalc.DefaultCount}") '// --- A Plugin needs a temporary, isolated context --- Using moduleCalc As New uCalc() moduleCalc.IsDefault = true '// Push the new instance onto the stack. Console.WriteLine($"Count after module pushes new default: {uCalc.DefaultCount}") '// The module's context is now active. '// uCalc::DefaultInstance() would now return 'moduleCalc'. End Using '// When 'moduleCalc' goes out of scope, it's destroyed and automatically '// removed from the stack, restoring the previous default. Console.WriteLine($"Count after module instance is disposed: {uCalc.DefaultCount}") '// Verify the original default instance is active again. Dim result = uCalc.DefaultInstance.EvalStr("PI") Console.WriteLine($"Original context restored. PI = {result}") End Sub End Module
ID: 161
using uCalcSoftware;
var uc = new uCalc();
// In C# and VB you should use "using".
// In C++ you can flag a uCalc object for
// auto-release with Owned(), or by setting
// the last parameter of the constructor to true.
uc.IsDefault = true; // Set uc as the default uCalc object
uCalc.DefaultInstance.DefineVariable("Value = 'Original uc object'");
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // Outputs: Original uc object
// Use "using" so that the object is auto-released when it it goes out of scope
using (var uCalcTemp = new uCalc()) {
uCalcTemp.IsDefault = true; // Set uCalcTemp as the default uCalc object
uCalc.DefaultInstance.DefineVariable("Value = 'uCalcTemp object'");
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // uCalcTemp object
}
// uCalcTemp goes out of scope here, and the default uCalc object reverts back to uc
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // Original uc object
{
/*using*/ var uCalcSticky = new uCalc(); // remains the default even after going out of scope
uCalcSticky.IsDefault = true; // Set uCalcSticky as the default uCalc object
uCalc.DefaultInstance.DefineVariable("Value = 'uCalcSticky object'");
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // Outputs: uCalcSticky object
} // The uCalcSticky object itself goes out of scope here, but internally it remains the default uCalc object
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value"));
Original uc object
uCalcTemp object
Original uc object
uCalcSticky object
uCalcSticky object using uCalcSoftware; var uc = new uCalc(); // In C# and VB you should use "using". // In C++ you can flag a uCalc object for // auto-release with Owned(), or by setting // the last parameter of the constructor to true. uc.IsDefault = true; // Set uc as the default uCalc object uCalc.DefaultInstance.DefineVariable("Value = 'Original uc object'"); Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // Outputs: Original uc object // Use "using" so that the object is auto-released when it it goes out of scope using (var uCalcTemp = new uCalc()) { uCalcTemp.IsDefault = true; // Set uCalcTemp as the default uCalc object uCalc.DefaultInstance.DefineVariable("Value = 'uCalcTemp object'"); Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // uCalcTemp object } // uCalcTemp goes out of scope here, and the default uCalc object reverts back to uc Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // Original uc object { /*using*/ var uCalcSticky = new uCalc(); // remains the default even after going out of scope uCalcSticky.IsDefault = true; // Set uCalcSticky as the default uCalc object uCalc.DefaultInstance.DefineVariable("Value = 'uCalcSticky object'"); Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // Outputs: uCalcSticky object } // The uCalcSticky object itself goes out of scope here, but internally it remains the default uCalc object Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// In C# and VB you should use "using".
// In C++ you can flag a uCalc object for
// auto-release with Owned(), or by setting
// the last parameter of the constructor to true.
uc.IsDefault(true); // Set uc as the default uCalc object
uCalc::DefaultInstance().DefineVariable("Value = 'Original uc object'");
cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // Outputs: Original uc object
{
uCalc uCalcTemp;
uCalcTemp.Owned(); // Causes uCalcTemp to be released when it goes out of scope // Make uCalcTemp owned so it reverts back to uc when uCalcTemp goes out of scope
uCalcTemp.IsDefault(true); // Set uCalcTemp as the default uCalc object
uCalc::DefaultInstance().DefineVariable("Value = 'uCalcTemp object'");
cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // uCalcTemp object
}
// uCalcTemp goes out of scope here, and the default uCalc object reverts back to uc
cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // Original uc object
{
uCalc uCalcSticky; // remains the default even after going out of scope
uCalcSticky.IsDefault(true); // Set uCalcSticky as the default uCalc object
uCalc::DefaultInstance().DefineVariable("Value = 'uCalcSticky object'");
cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // Outputs: uCalcSticky object
} // The uCalcSticky object itself goes out of scope here, but internally it remains the default uCalc object
cout << uCalc::DefaultInstance().EvalStr("Value") << endl;
}
Original uc object
uCalcTemp object
Original uc object
uCalcSticky object
uCalcSticky object #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // In C# and VB you should use "using". // In C++ you can flag a uCalc object for // auto-release with Owned(), or by setting // the last parameter of the constructor to true. uc.IsDefault(true); // Set uc as the default uCalc object uCalc::DefaultInstance().DefineVariable("Value = 'Original uc object'"); cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // Outputs: Original uc object { uCalc uCalcTemp; uCalcTemp.Owned(); // Causes uCalcTemp to be released when it goes out of scope // Make uCalcTemp owned so it reverts back to uc when uCalcTemp goes out of scope uCalcTemp.IsDefault(true); // Set uCalcTemp as the default uCalc object uCalc::DefaultInstance().DefineVariable("Value = 'uCalcTemp object'"); cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // uCalcTemp object } // uCalcTemp goes out of scope here, and the default uCalc object reverts back to uc cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // Original uc object { uCalc uCalcSticky; // remains the default even after going out of scope uCalcSticky.IsDefault(true); // Set uCalcSticky as the default uCalc object uCalc::DefaultInstance().DefineVariable("Value = 'uCalcSticky object'"); cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // Outputs: uCalcSticky object } // The uCalcSticky object itself goes out of scope here, but internally it remains the default uCalc object cout << uCalc::DefaultInstance().EvalStr("Value") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// In C# and VB you should use "using".
'// In C++ you can flag a uCalc object for
'// auto-release with Owned(), or by setting
'// the last parameter of the constructor to true.
uc.IsDefault = true '// Set uc as the default uCalc object
uCalc.DefaultInstance.DefineVariable("Value = 'Original uc object'")
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Outputs: Original uc object
'// Use "using" so that the object is auto-released when it it goes out of scope
Using uCalcTemp As New uCalc()
uCalcTemp.IsDefault = true '// Set uCalcTemp as the default uCalc object
uCalc.DefaultInstance.DefineVariable("Value = 'uCalcTemp object'")
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// uCalcTemp object
End Using
'// uCalcTemp goes out of scope here, and the default uCalc object reverts back to uc
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Original uc object
If True Then
Dim uCalcSticky As New uCalc() '// remains the default even after going out of scope
uCalcSticky.IsDefault = true '// Set uCalcSticky as the default uCalc object
uCalc.DefaultInstance.DefineVariable("Value = 'uCalcSticky object'")
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Outputs: uCalcSticky object
End If '// The uCalcSticky object itself goes out of scope here, but internally it remains the default uCalc object
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value"))
End Sub
End Module
Original uc object
uCalcTemp object
Original uc object
uCalcSticky object
uCalcSticky object Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// In C# and VB you should use "using". '// In C++ you can flag a uCalc object for '// auto-release with Owned(), or by setting '// the last parameter of the constructor to true. uc.IsDefault = true '// Set uc as the default uCalc object uCalc.DefaultInstance.DefineVariable("Value = 'Original uc object'") Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Outputs: Original uc object '// Use "using" so that the object is auto-released when it it goes out of scope Using uCalcTemp As New uCalc() uCalcTemp.IsDefault = true '// Set uCalcTemp as the default uCalc object uCalc.DefaultInstance.DefineVariable("Value = 'uCalcTemp object'") Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// uCalcTemp object End Using '// uCalcTemp goes out of scope here, and the default uCalc object reverts back to uc Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Original uc object If True Then Dim uCalcSticky As New uCalc() '// remains the default even after going out of scope uCalcSticky.IsDefault = true '// Set uCalcSticky as the default uCalc object uCalc.DefaultInstance.DefineVariable("Value = 'uCalcSticky object'") Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Outputs: uCalcSticky object End If '// The uCalcSticky object itself goes out of scope here, but internally it remains the default uCalc object Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) End Sub End Module